using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class REFERGDInfo
    {
		#region Local Variable
		public enum Field
		{
			NGAYGD,
			KHOASO,
			SOCT,
			PHUCHOI
		}
		private DateTime _NGAYGD;
		private Boolean _KHOASO;
		private String _SOCT;
		private Boolean _PHUCHOI;
		
		public DateTime NGAYGD{	get{ return _NGAYGD;} set{_NGAYGD = value;} }
		public Boolean KHOASO{	get{ return _KHOASO;} set{_KHOASO = value;} }
		public String SOCT{	get{ return _SOCT;} set{_SOCT = value;} }
		public Boolean PHUCHOI{	get{ return _PHUCHOI;} set{_PHUCHOI = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public REFERGDInfo()
		{
			_NGAYGD = DateTime.Now;
			_KHOASO = true;
			_SOCT = "";
			_PHUCHOI = true;
		}
		public REFERGDInfo(
		DateTime NGAYGD,
		Boolean KHOASO,
		String SOCT,
		Boolean PHUCHOI
		)
		{
			_NGAYGD = NGAYGD;
			_KHOASO = KHOASO;
			_SOCT = SOCT;
			_PHUCHOI = PHUCHOI;
		}
		public REFERGDInfo(DataRow dr)
		{
			if (dr != null)
			{
				_NGAYGD = dr[Field.NGAYGD.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.NGAYGD.ToString()]);
				_KHOASO = dr[Field.KHOASO.ToString()] == DBNull.Value?true:Convert.ToBoolean(dr[Field.KHOASO.ToString()]);
				_SOCT = dr[Field.SOCT.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SOCT.ToString()]);
				_PHUCHOI = dr[Field.PHUCHOI.ToString()] == DBNull.Value?true:Convert.ToBoolean(dr[Field.PHUCHOI.ToString()]);
			}
		}
		public REFERGDInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_NGAYGD = dr[Field.NGAYGD.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.NGAYGD.ToString()]);
				_KHOASO = dr[Field.KHOASO.ToString()] == DBNull.Value?true:Convert.ToBoolean(dr[Field.KHOASO.ToString()]);
				_SOCT = dr[Field.SOCT.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SOCT.ToString()]);
				_PHUCHOI = dr[Field.PHUCHOI.ToString()] == DBNull.Value?true:Convert.ToBoolean(dr[Field.PHUCHOI.ToString()]);
			}
		}
		public REFERGDInfo(REFERGDInfo objEntr)
		{			
			_NGAYGD = objEntr.NGAYGD;			
			_KHOASO = objEntr.KHOASO;			
			_SOCT = objEntr.SOCT;			
			_PHUCHOI = objEntr.PHUCHOI;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("REFERGD");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.NGAYGD.ToString(), typeof(DateTime)),
				new DataColumn(Field.KHOASO.ToString(), typeof(Boolean)),
				new DataColumn(Field.SOCT.ToString(), typeof(String)),
				new DataColumn(Field.PHUCHOI.ToString(), typeof(Boolean))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.NGAYGD.ToString()] = _NGAYGD;
			row[Field.KHOASO.ToString()] = _KHOASO;
			row[Field.SOCT.ToString()] = _SOCT;
			row[Field.PHUCHOI.ToString()] = _PHUCHOI;
			return row;
		}
        #endregion InitTable
    }
}
